<template>
  <div>
    <el-dialog
      title="编辑会员"
      :visible.sync="obj.istrue"
      width="50%"
      :before-close="handleClose"
    >
      <el-form ref="form" :model="form" label-width="80px">
        <el-form-item label="手机号">
          <el-input v-model="form.phone"></el-input>
        </el-form-item>
        <el-form-item label="昵称">
          <el-input v-model="form.nickname"></el-input>
        </el-form-item>
        <el-form-item label="密码">
          <el-input v-model="form.password"></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="quxiao()">取 消</el-button>
        <el-button type="primary" @click="bianji()">编 辑</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { memberinfo, memberedit } from "../../../request/api";
import {mapActions,mapGetters} from 'vuex'
import {successAlert,warningAlert} from '../../../util/alert'
export default {
  props: ["obj"],
  data() {
    return {
      form: {
        password: "",
        nickname: "",
        status: "",
        phone: "",
      },
    };
  },
  methods: {
      ...mapActions({
          reqchangelist:'member/reqchangelist'
      }),
    //   点击弹框x执行的回调函数
    handleClose() {
      this.quxiao();
    },
    // 清空数据
    empty() {
      this.form = {
        password: "",
        nickname: "",
        status: 1,
        phone: "",
      };
    },
    // 点击取消
    quxiao() {
      // 取消弹窗
      this.obj.istrue = false;
      //   清空内容
      this.empty();
    },
    // 获取一条
    getinfo(uid) {
      memberinfo({ uid: uid }).then((res) => {
        this.form = res.data.list;
        this.form.uid=uid
      });
    },
    // 点击编辑
    bianji() {
      // console.log(this.form);
      memberedit(this.form).then((res) => {
        if (res.data.code == 200) {
          successAlert(res.data.msg);
          // 关闭弹框清空内容
          this.quxiao();
          // 刷新列表
          this.reqchangelist();
        } else {
          warningAlert(res.data.msg);
        }
      });
    },
  },
  computed:{
      ...mapGetters({
          memberlist:'member/list'
      })
  }
};
</script>

<style scoped>
</style>